import request from '@/utils/request'
import { ObjToQueryString } from '@/utils/method'
const baseUrl = process.env.VUE_APP_BASE_API

// 平台当前数据
export const platformHistory = (params) => {
  return request({
    url: '/statics/platform/history',
    params,
    method: 'get'
  })
}
// 平台转化数据
export const promotionConversion = (params) => {
  return request({
    url: '/statements/platform/promotionconversion',
    params,
    method: 'get'
  })
}
export const promotionConversionDetail = (params) => {
  return request({
    url: '/statements/platform/promotionconversionDetail',
    params,
    method: 'get'
  })
}
export const promotionConversionExport = (params) => {
  const url = `/statements/platform/promotionconversion/export/${params.channelId}`
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 平台用户埋点
export const platformUsersBuried = (params) => {
  return request({
    url: '/statements/platform',
    params,
    method: 'get'
  })
}
export const platformUsersBuriedList = (params) => {
  return request({
    url: '/statements/platform/list',
    params,
    method: 'get'
  })
}
// vtg-到期日期
export const vtgDueamount = (params) => {
  return request({
    url: '/vtg/dueamount',
    params,
    method: 'get'
  })
}
export const exportVtgDueamount = (params) => {
  const url = '/vtg/dueamount/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
export const vtgDuecount = (params) => {
  return request({
    url: '/vtg/duecount',
    params,
    method: 'get'
  })
}
export const exportVtgDuecount = (params) => {
  const url = '/vtg/duecount/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 平台运营数据
export const platformOperate = (params) => {
  return request({
    url: '/statements/platform/operate',
    params,
    method: 'get'
  })
}
export const platformOperateDetail = (params) => {
  return request({
    url: '/statements/platform/operate/detail',
    params,
    method: 'get'
  })
}
export const platformOperateDetailExport = (params) => {
  const url = '/statements/platform/operate/detail/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// vtg-放款日期
export const paymentAmount = (params) => {
  return request({
    url: '/vtg/paymentamount',
    params,
    method: 'get'
  })
}
export const paymentAmountTotal = (params) => {
  return request({
    url: '/vtg/paymentamount/total',
    params,
    method: 'get'
  })
}
export const paymentAmountExport = (params) => {
  const url = '/vtg/paymentamount/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
export const paymentCount = (params) => {
  return request({
    url: '/vtg/paymentcount',
    params,
    method: 'get'
  })
}
export const paymentCountTotal = (params) => {
  return request({
    url: '/vtg/paymentcount/total',
    params,
    method: 'get'
  })
}
export const paymentCountExport = (params) => {
  const url = '/vtg/paymentcount/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 注册-申请转化漏斗
export const reportPackages = () => {
  return request({
    url: '/report/packages',
    method: 'get'
  })
}
export const reportVersions = () => {
  return request({
    url: '/report/versions',
    method: 'get'
  })
}
export const register2apply = (params) => {
  return request({
    url: '/report/register2apply',
    params,
    method: 'get'
  })
}
export const register2applyExport = (params) => {
  const url = '/report/register2apply/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
